//
//  DZZEvaluateTableViewCell.m
//  DZZTravel
//
//  Created by xalo on 16/7/18.
//  Copyright © 2016年 Eason. All rights reserved.
//

#import "DZZEvaluateTableViewCell.h"

@interface DZZEvaluateTableViewCell ()<UICollectionViewDataSource,UICollectionViewDelegate>

@property (nonatomic,strong)NSMutableArray *muArray;

@property (nonatomic,strong)NSMutableArray *imageArray;


@end

@implementation DZZEvaluateTableViewCell


- (NSMutableArray *)imageArray{
    if (!_imageArray) {
        _imageArray = [NSMutableArray array];
    }
    return _imageArray;
}

- (NSMutableArray *)muArray{
    if (!_muArray) {
        _muArray = [NSMutableArray array];
    }
    return _muArray;
}

- (void)awakeFromNib {
    // Initialization code
    
    self.collection.delegate = self;
    self.collection.dataSource = self;
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    //设置滑动方向
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    //    设置item的大小
    self.collection.backgroundColor = [UIColor whiteColor];
    layout.itemSize = CGSizeMake(([UIScreen mainScreen].bounds.size.width-20)/3, 80);
    //    设置间距
    layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
    layout.minimumInteritemSpacing = 5;
    self.collection.collectionViewLayout = layout;
    
    
    [self.collection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    
//    icon变圆
    self.iconImageView.layer.cornerRadius = self.iconImageView.width/2;
    self.iconImageView.clipsToBounds = YES;
    
//    注册cell
    [self.collection registerNib:[UINib nibWithNibName:@"DZZEvaCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"DZZEvaCollectionCell"];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return self.muArray.count ;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    
    DZZEvaCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DZZEvaCollectionCell" forIndexPath:indexPath];
    
    
    if (self.muArray.count>0) {
        
            NSString *string = [NSString stringWithFormat:@"http://cdn5.yaochufa.com/%@",self.muArray [indexPath.row][@"imageURL"]];
    
    [cell.imv sd_setImageWithURL:[NSURL URLWithString:string] placeholderImage:[UIImage imageNamed:@"bs"]];
        }
    
    return cell;
}
////传过来一个array
//- (void)setCellOfTheArray:(NSMutableArray *)array{
//    self.muArray = array;
//    [self.collection reloadData];
//    
//    
//}

- (void)setCellForModel:(DZZEvaluateModel *)CellModel{
    DZZEvaluateModel *cellMo = CellModel;
    
    self.iconImageView.image = [UIImage imageNamed:@"bs"];
    
            self.nameLabel.text = cellMo.customerName;
            if ([cellMo.rate  isEqual: @4]) {
                self.starLabel.text = @"⭐️⭐️⭐️⭐️";
            }else{
                self.starLabel.text = @"⭐️⭐️⭐️⭐️⭐️";
            }
            self.numberLabel.text = [NSString stringWithFormat:@"%@.0",cellMo.rate.description];
    self.talkLabel.text = cellMo.content;
    
    self.muArray = cellMo.commnentImages;
    
    
   
    
    [self.collection reloadData];
    
    
    
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
//    ZoomImage showImage:[]
   DZZEvaCollectionCell *cell =(DZZEvaCollectionCell *)[collectionView cellForItemAtIndexPath:indexPath];
    
    [ZoomImage showImage:cell.imv];
    
    
}


////传过来图片的Array
//- (void)setImageOfTheArray:(NSMutableArray *)array{
//    self.imageArray = array;
//    [self.collection reloadData];
//    
//}
/*
 
 {
 "data": {
 "personCount": 7,
 "commentCount": 7,
 "averageRate": 4.7,
 "allCountTip": "全部",
 "hasPictureCountTip": "有图(4)",
 "goodRateCountTip": "好评(7)",
 "middleRateCountTip": "中评(0)",
 "badRateCountTip": "差评(0)",
 "goodRateCount": 7,
 "middleRateCount": 0,
 "badRateCount": 0,
 "commentInfos": [
 {
 "customerName": "曹**",
 "sex": "女",
 "customerPicUrl": null,
 "growthLevel": 8,
 "memberLevel": 1,
 "iconUrl": "http://cdn7.yaochufa.com/m/images/level/app/head_silver_member_icon.png",
 "imageCount": 4,
 "isHasSetGood": false,
 "travelType": "家庭亲子",
 "replyTime": "",
 "productPackageName": "秦岭野生动物园成人票1张",
 "commentId": 332697,
 "commentDate": "2016-07-18",
 "rate": 5,
 "highQualityStatus": 1,
 "goodCount": 0,
 "content": "开车自驾去的，但是被村民忽悠的花了四十带着我们开到村口停车说离上面近，实在是不值！今天阴天树下很凉快，走走停停看看还是不错，个人觉得虽然动物有点儿少，感觉灵长类的动物偏多，我娃就看了一整猴子，花了一块钱买的沙果喂猴子，感觉挺好的！个人比较喜欢澳洲的驼羊，小浣熊类！里面吃的用的太贵，觉得坑人不是一点儿啊！不过总体来说还好吧",
 "commnentImages": [
 {
 "imageURL": "images/comment/2016/7/332697_4942d75cdb4b456eaceef083173fa9d3.jpg",
 "sortBy": 1
 },
 {
 "imageURL": "images/comment/2016/7/332697_c056e0db49c746568a1324da8fce1917.jpg",
 "sortBy": 2
 },
 {
 "imageURL": "images/comment/2016/7/332697_a46895ac7dd94c68a19b20ceaade54b4.jpg",
 "sortBy": 3
 },
 {
 "imageURL": "images/comment/2016/7/332697_9d5c1e1565334dbd8965042f3b55b9a4.jpg",
 "sortBy": 4
 }
 ],
 "ycfReply": null
 },
 {
 "customerName": "k**",
 "sex": "女",
 "customerPicUrl": null,
 "growthLevel": 8,
 "memberLevel": 1,
 "iconUrl": "http://cdn7.yaochufa.com/m/images/level/app/head_silver_member_icon.png",
 "imageCount": 1,
 "isHasSetGood": false,
 "travelType": "家庭亲子",
 "replyTime": "",
 "productPackageName": "秦岭野生动物园成人票1张",
 "commentId": 332696,
 "commentDate": "2016-07-18",
 "rate": 5,
 "highQualityStatus": 0,
 "goodCount": 0,
 "content": "天气太热，动物都睡觉",
 "commnentImages": [
 {
 "imageURL": "images/comment/2016/7/332696_0f692424ed604d07ae4009b957491187.jpg",
 "sortBy": 1
 }
 ],
 "ycfReply": null
 },
 {
 "customerName": "曹**",
 "sex": "女",
 "customerPicUrl": null,
 "growthLevel": 8,
 "memberLevel": 1,
 "iconUrl": "http://cdn7.yaochufa.com/m/images/level/app/head_silver_member_icon.png",
 "imageCount": 1,
 "isHasSetGood": false,
 "travelType": "家庭亲子",
 "replyTime": "",
 "productPackageName": "秦岭野生动物园成人票1张",
 "commentId": 332695,
 "commentDate": "2016-07-18",
 "rate": 5,
 "highQualityStatus": 0,
 "goodCount": 0,
 "content": "总体来说还可以，就是动物太少了",
 "commnentImages": [
 {
 "imageURL": "images/comment/2016/7/332695_14c4776910594057bc95f10c34ca5979.jpg",
 "sortBy": 1
 }
 ],
 "ycfReply": null
 },
 {
 "customerName": "R**",
 "sex": "女",
 "customerPicUrl": "images/customerimage/2718234/f8f1116eb3174784a22fb27c8f2d3775.jpg",
 "growthLevel": 7,
 "memberLevel": 4,
 "iconUrl": "http://cdn7.yaochufa.com/m/images/level/app/head_diamond_member_icon.png",
 "imageCount": 3,
 "isHasSetGood": false,
 "travelType": "家庭亲子",
 "replyTime": "",
 "productPackageName": "秦岭野生动物园成人票1张",
 "commentId": 318678,
 "commentDate": "2016-05-30",
 "rate": 5,
 "highQualityStatus": 0,
 "goodCount": 0,
 "content": "特别好！但是如果带老人或者小孩的话，建议花80块钱坐个小火车，那个性价比高，去猛兽区坐的笼子车，可以下车喂长颈鹿什么的。还有园区里的小火车也是随便坐。",
 "commnentImages": [
 {
 "imageURL": "images/comment/2016/5/318678_d841d640ef0d4b2dbf087b90a2d0f238.jpg",
 "sortBy": 1
 },
 {
 "imageURL": "images/comment/2016/5/318678_30d26254cc0e44c28fe4a5a8556c0419.jpg",
 "sortBy": 2
 },
 {
 "imageURL": "images/comment/2016/5/318678_830fd66435944284b5f0d00793df5bbc.jpg",
 "sortBy": 3
 }
 ],
 "ycfReply": null
 },
 {
 "customerName": "郑**",
 "sex": "男",
 "customerPicUrl": null,
 "growthLevel": 11,
 "memberLevel": 1,
 "iconUrl": "http://cdn7.yaochufa.com/m/images/level/app/head_silver_member_icon.png",
 "imageCount": null,
 "isHasSetGood": false,
 "travelType": "夫妻情侣",
 "replyTime": "",
 "productPackageName": "秦岭野生动物园成人票1张",
 "commentId": 307130,
 "commentDate": "2016-04-17",
 "rate": 5,
 "highQualityStatus": 0,
 "goodCount": 0,
 "content": "超快，门口订都可以。\n",
 "commnentImages": [],
 "ycfReply": null
 },
 {
 "customerName": "D**",
 "sex": "男",
 "customerPicUrl": null,
 "growthLevel": 1,
 "memberLevel": 1,
 "iconUrl": "http://cdn7.yaochufa.com/m/images/level/app/head_silver_member_icon.png",
 "imageCount": null,
 "isHasSetGood": false,
 "travelType": null,
 "replyTime": "",
 "productPackageName": "秦岭野生动物园成人票1张",
 "commentId": 301231,
 "commentDate": "2016-03-28",
 "rate": 4,
 "highQualityStatus": 0,
 "goodCount": 0,
 "content": "还可以",
 "commnentImages": [],
 "ycfReply": null
 },
 {
 "customerName": "党**",
 "sex": "未填写",
 "customerPicUrl": null,
 "growthLevel": 1,
 "memberLevel": 0,
 "iconUrl": "http://cdn7.yaochufa.com/m/images/level/app/head_common_member_icon.png",
 "imageCount": null,
 "isHasSetGood": false,
 "travelType": null,
 "replyTime": "",
 "productPackageName": "秦岭野生动物园成人票1张+园内午餐1份",
 "commentId": 202706,
 "commentDate": "2015-08-10",
 "rate": 4,
 "highQualityStatus": 0,
 "goodCount": 0,
 "content": "400客服理解能力真差，只会像复读机一样重复。",
 "commnentImages": [],
 "ycfReply": null
 }
 ]
 },
 "success": true,
 "message": "获取成功！",
 "statusCode": 200
 }
 
 
 */


@end
